﻿#include "comparenumber.h"

CompareNumber::CompareNumber(QObject *parent) : QObject(parent)
{
    
}

QString CompareNumber::Should_return_xAxB_Given_two_four_digits_that_no_repeat(QString answer, QString user_input)
{
    int right_num = 0, error_num = 0;
    for(int i = 0; i < user_input.length(); ++i)
    {
        if(user_input.at(i) == answer.at(i))
        {
            right_num++;
        }
        else
        {
            error_num++;
        }
    }
    QString result = QString::number(right_num) + "A" + QString::number(error_num) + "B";
    return result;
}
